﻿Public Class Planilla 

    Private Sub PlanillasBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles PlanillasBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PlanillasBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbFireAndIceDataSet)
    End Sub

    Private Sub Planilla_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.pagosminutosmarca' table. You can move, or remove it, as needed.
        Me.PagosminutosmarcaTableAdapter.Fill(Me.DbFireAndIceDataSet.pagosminutosmarca)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.registromarcas' table. You can move, or remove it, as needed.
        Me.RegistromarcasTableAdapter.Fill(Me.DbFireAndIceDataSet.registromarcas)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.remuneraciones' table. You can move, or remove it, as needed.
        Me.RemuneracionesTableAdapter.Fill(Me.DbFireAndIceDataSet.remuneraciones)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.empleadosdeduccion' table. You can move, or remove it, as needed.
        Me.EmpleadosdeduccionTableAdapter.Fill(Me.DbFireAndIceDataSet.empleadosdeduccion)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.cargos' table. You can move, or remove it, as needed.
        Me.CargosTableAdapter.Fill(Me.DbFireAndIceDataSet.cargos)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.empleados' table. You can move, or remove it, as needed.
        Me.EmpleadosTableAdapter.Fill(Me.DbFireAndIceDataSet.empleados)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.planillasdetalle' table. You can move, or remove it, as needed.
        Me.PlanillasdetalleTableAdapter.Fill(Me.DbFireAndIceDataSet.planillasdetalle)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.planillas' table. You can move, or remove it, as needed.
        Me.PlanillasTableAdapter.Fill(Me.DbFireAndIceDataSet.planillas)
    End Sub

    Private Sub IdempleadoLookUpEdit_EditValueChanged(sender As System.Object, e As System.EventArgs) Handles IdempleadoLookUpEdit.EditValueChanged
        If Not IsDBNull(IdempleadoLookUpEdit) Then  'si no es nulo el lookupedit

            TextEdit1.EditValue = IdempleadoLookUpEdit.GetColumnValue("apellido")
            TextEdit2.EditValue = IdempleadoLookUpEdit.GetColumnValue("sueldobase")
            TextEdit4.EditValue = IdempleadoLookUpEdit.GetColumnValue("idcargo")

            PictureEdit1.EditValue = IdempleadoLookUpEdit.GetColumnValue("fotografia")
            TextEdit3.EditValue = IdempleadoLookUpEdit.GetColumnValue("idempleado")
            ''Calculos
            SueldofinalTextEdit.Text = Val(SueldofinalTextEdit.Text) + Val(TextEdit2.Text)

            TotaldeduccionTextEdit.Text = Val(EmpleadosdeduccionTableAdapter.ScalarQuerySumaDeLasDeduccionesPorEmpleado(Val(TextEdit3.Text)))
            TotalremunTextEdit.Text = Val(RemuneracionesTableAdapter.ScalarQuerySumaTotalDeRemuneracionesPorEmpleado(Val(TextEdit3.Text)))


            SueldofinalTextEdit.EditValue = ((Val(TextEdit2.EditValue) + Val(TotalremunTextEdit.EditValue) - Val(TotaldeduccionTextEdit.EditValue)))
        Else
            MsgBox("Ingrese empleado")
        End If
    End Sub
    Private Sub IdplanillaTextEdit_EditValueChanged(sender As System.Object, e As System.EventArgs) Handles IdplanillaTextEdit.EditValueChanged
        'IdplanillaTextEdit.EditValue = IdplanillaTextEdit.EditValue + 1
        IdplanillaTextEdit1.EditValue = IdplanillaTextEdit.EditValue
    End Sub
End Class